<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------
namespace addon\mall\model;
use \think\Request;
use app\common\model\AddonBase;
class Goods extends AddonBase
{
	protected $insert = ["add_time"];
	protected $auto = ['last_update_time']; 

	protected function setAddTimeAttr(){
		return time();
	}

	protected function setLastUpdateTimeAttr(){
		return time();
	}

    protected function setPromoteStartDateAttr($value){
    	return strtotime($value);
    }
    protected function setPromoteEndDateAttr($value){
    	return strtotime($value);
    }
    protected function setShortDescribeAttr($value){
    	if(empty($value)){
    		return substr(htmlspecialchars(strip_tags(input("content"))),0,200);
    	}
        return $value;
    }
    protected function getGoodsThumbAttr($value){
        if ($value && !preg_match('/^http(s)?:\\/\\/.+/', $value)) {
            return SITE_PATH . $value;
        } else {
            return $value;
        }
    }
}
